<?php

//
// THE DAILY PEN
// By Christian Touzel
//

// GLOBAL TIMEZONE SET
date_default_timezone_set('America/Montreal');

// INCLUDED PHP FILES
include("dailypenfunctions.php");
include("rss.php");
include("twitter.php");
include("mlb.php");

// CONSTANTS
$version = "1.0.1.10001";

// GLOBAL VARIABLES
$GLOBALS['errors'] = "";

// GLOBAL ERROR HANDLER
set_error_handler("ManageDailyPenErrors");

// HEADER - error safe
echo GetDailyPenHeader($version);

// RANDOM QUOTE - error safe
echo GetRandomQuote();

// WEATHER - error safe
echo GetWeather(true);
echo GetWeather(false);

// NEWS HEADLINES - error safe
$headlines = array(
	"http://rss.radio-canada.ca/fils/regions/quebec.xml",
	"http://rss.radio-canada.ca/fils/regions/estduquebec.xml",
	"http://rss.radio-canada.ca/fils/nouvelles/international.xml",
	"http://www.cyberpresse.ca/rss/225.xml",
	"http://www.cyberpresse.ca/rss/501.xml");
echo "<h3>DERNIERE HEURE</h3>".PHP_EOL;
echo GetHeadlinesFromRSS($headlines, 8, 0);

// BASEBALL NEWS HEADLINES - error safe
echo "<h3>BASEBALL</h3>".PHP_EOL;
echo GetHeadlinesFromRSS("http://mlb.mlb.com/partnerxml/gen/news/rss/mlb.xml", 8, 0);

// TWITTER
echo "<h3>TWITTER</h3>".PHP_EOL;
echo GetTwitterTimeline();

// MLB NEWS
echo ReadFromRSS("http://mlb.mlb.com/partnerxml/gen/news/rss/mlb.xml", "MLB NEWS", 7, false, 0);

// MLB SCORES
echo "<h3>MLB SCORES</h3>".PHP_EOL;
GetMLBScoresTables();

// MLB STANDINGS
echo "<h3>MLB STANDINGS</h3>".PHP_EOL;
GetMLBStandings().PHP_EOL;

// MLB STATS
echo "<h3>MLB STATS</h3>".PHP_EOL;
GetMLBStats().PHP_EOL;

// ARTICLES
echo ReadFromRSS(array('http://joeposnanski.com/joeblogs/feed/','http://www.nbcsports.com/rss/author/joe-posnanski/feed/'), "JOE POSNANSKI", 1, true, 0);
echo ReadFromRSS("http://sports.yahoo.com/mlb/blog/big_league_stew/rss.xml", "KEVIN KADUK", 1, true, 0);

// LOG REPORTS
echo "<h3>ERRORS REPORT</h3>";
$now = new DateTime();
echo $GLOBALS['errors'];
echo "<p style='font-size: 80%;'>The Daily Pen ".$version." is a creation of Christian Touzel. ";
echo "Page generated on ".$now->format('F j, Y H:i:s').". PHP version is ".phpversion()."</p>";


// END OF WEBPAGE
echo "</section></article>";
echo "</body>";
echo "</html>";
?>